<!DOCTYPE html>
<html ><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>找回密码</title>
    
		<link href="../css/themes/default/easyui.css" rel="stylesheet" />
    <link href="../css/screen.css" type="text/css" rel="stylesheet">
		<script type="text/javascript" src="../script/jquery.min.js"></script>
    <link href="../css/bootstrap.min.css" type="text/css" rel="stylesheet"/>
		<script src="../script/jquery.easyui.min.js"></script>
    <script src="../script/checkUser.js"></script>
		<script src="../script/jquery.cookie.js"></script>
   </head>

  <body>
    <div class="openlab-masthead">
      <div class="container">
        <div class="logo col-sm-2">
          <img src="../img/logo.gif">
        </div>
        <div class="col-sm-7">
          <p class="openlab-slogan">
            我们曾经走过一样的岁月，也曾经为一样的事情流泪和欢笑，<br>
            我们宁愿忽视那些不同的想法和生活方式；<br>
            我们坚信，虽然我们的样子已经被社会打磨成千面，但是体温相似，情有共通。
          </p>
        </div>
          <div class="header-profile">
          </div>
      </div>
    </div>
    
    <div class="openlab-navbar">
      <div class="container">
        <ul class="openlab-nav">
          <li class="active"><a href=""><i class="glyphicon glyphicon-home"></i> 首页</a></li>
					<li class="active"><a href="login.html"><i class="glyphicon glyphicon-home"></i> 登陆</a></li>
        </ul>
  </div>
    </div>
    <div class="container openlab-main">

      


<div class="row">
    <div class="col-sm-offset-4 col-sm-4">
        <form class="form-signin" >
            <h2 class="form-heading">找回密码</h2>
            <hr>
                <div class="form-group ">
                <label for="username">登录名</label>
                <input class="form-control" id="id" maxlength="128"  placeholder="账号ID" type="text" value="" onchange="checkID()">
                <span class="help-block" style="color: red;" id="idMsg"></span>
            </div>
            <div class="form-group ">
                <label for="password">姓名</label>
                <input class="form-control" id="name" maxlength="20"  placeholder="姓名" type="text" value="" onchange="checkName()">
                <span class="help-block" style="color: red;" id="nameMsg"></span>
            </div>
						<div class="form-group ">
						    <label for="password">手机号码</label>
						    <input class="form-control" id="phoneNumber" maxlength="20" placeholder="手机号码" type="text" value="" onchange="checkPhone()">
						    <span class="help-block" style="color: red;" id="phoneMsg"></span>
						</div>
            <div class="form-group ">
                <label for="password">身份证号码</label>
                <input class="form-control" id="idCard" maxlength="20" name="password" placeholder="身份证号码" type="text" value="" onchange="checkIdCard()">
                <span class="help-block" style="color: red;" id="idCardMsg"></span>
            </div>
            <button class="btn btn-lg btn-primary btn-block" onclick="findPw()" type="button">找回密码</button>
        </form>

    </div>
	<script type="text/javascript">
		var idIsOk=false;
		function checkID()
		{
			function check(id){
				var reg=/^[0-9]*$/;
				return !reg.test(id);
			}
			var id=$("#id").val();
			if(id=="")
			{
				idIsOk=false;
				$("#idMsg").html("×id不能为空")
			}else if(check(id)){
				idIsOk=false;
				$("#idMsg").html("×id格式为数字");
			}
			else{
				var par={id:id};
				$.ajax({
					type:"post",
					contentType :'application/x-www-form-urlencoded;charset=utf-8',
					dataType:"json",  //数据格式设置为jsonp
					url : 'http://localhost:8080/libManager/user/findById.do',
					data:par, //额外的参数
					success:function (data) 
					{
						if(data.status==1)
						{
							idIsOk=false;
							$("#idMsg").html("×未找到该用户！");
						}else
						{
							idIsOk=true;
							$("#idMsg").html("");
						}
					}
				});
			}
		}
	function checkAll()
	{
		if(!idIsOk)
		{
			checkID();
			if(!idIsOk)
			{
				return false;
			}
		}
		if(!checkName())
		{
			return false;
		}
		if(!checkPhone())
		{
			return false;
		}
		if(!checkIdCard())
		{
			return false;
		}
		return true;
	}
	function findPw()
	{
		if(checkAll())
		{
			var pars=
			{
				id:$("#id").val(),
				name:$("#name").val(),
				phoneNumber:$("#phoneNumber").val(),
				idCard:$("#idCard").val(),
			}
			$.ajax({
				type:"post",
				contentType :'application/json;charset=utf-8',
				dataType:"json",  //数据格式设置为jsonp
				url : 'http://localhost:8080/libManager/user/checkMsg.do',
				data:JSON.stringify(pars), //额外的参数
				success:function (data) 
				{
					if(data.status==1)
					{
						$.cookie('uuidc', data.url);
						$(location).attr('href', 'changePwByFind.html');
					}else
					{
						$.messager.alert('系统提示', data.msg);
					}
				}
			});
		}else
		{
			$.messager.alert("系统提醒","部分信息没有完善或格式不对！！");
		}
	}
	</script>
</body></html>